package com.jalarbee.core.user.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jalarbee.core.generic.dao.GenericDao;
import com.jalarbee.core.generic.service.impl.GenericServiceImpl;
import com.jalarbee.core.user.business.User;
import com.jalarbee.core.user.dao.UserDao;
import com.jalarbee.core.user.dao.exception.NoSuchUserFound;
import com.jalarbee.core.user.service.UserService;
import com.jalarbee.core.user.util.UserFilter;
import com.jalarbee.core.util.Chunk;

@Service(value = "userService")
@Transactional(readOnly = false)
public class UserServiceImpl extends GenericServiceImpl<User, Integer> implements UserService {

    @Autowired
    protected void setDao(@Qualifier(value = "userDao") GenericDao<User, Integer> dao) {
        this.dao = dao;
    }

    public List<User> findUsers(UserFilter filter, Chunk chunk) {
        return ((UserDao) dao).find(filter, chunk);
    }

    public User findUserByName(String userName) throws NoSuchUserFound {
        return ((UserDao) dao).findUserByName(userName);
    }
}